#ifndef __LOG__
#define __LOG__

#include "builder.hpp"

namespace define_log
{
    log_p::Logger::ptr RoolLogger()
    {
        return log_p::SingletonBuilderLogger::GetInstance()->GetRoolLogger();
    }

    log_p::Logger::ptr GetLogger(const std::string &logger_name)
    {
        return log_p::SingletonBuilderLogger::GetInstance()->GetLogger(logger_name);
    }

// 定义宏，用于自动获取文件名和行号，并且可以接受任意的日志记录器对象名,方便用户不用操作全局日志器
#define LOG_DEBUG(logger_name, fmt, ...) \
    GetLogger(logger_name)->Debug(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define LOG_INFO(logger_name, fmt, ...) \
    GetLogger(logger_name)->Info(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define LOG_FAIL(logger_name, fmt, ...) \
    GetLogger(logger_name)->Fail(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define LOG_WARN(logger_name, fmt, ...) \
    GetLogger(logger_name)->Warn(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

// 调用默认日志器
#define DEBUG(fmt, ...) \
    RoolLogger()->Debug(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define INFO(fmt, ...) \
    RoolLogger()->Info(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define FAIL(fmt, ...) \
    RoolLogger()->Fail(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

#define WARN(fmt, ...) \
    RoolLogger()->Warn(__FILE__, __LINE__, fmt, ##__VA_ARGS__)

    void InitOverAllLogger(const std::string &log_name = "root-log", log_p::LoggerType it = log_p::LoggerType::LOGGER_ASYN)
    {
        static auto Z1 = log_p::SingletonBuilderLogger::GetInstance(log_name, it);
        Z1->builder_formater("[%d][%p]%T%m%T  [%f][%l][%c][%t]%n");
        Z1->builder_level(log_p::log_level::INFO);
        Z1->builder_sink_pool<log_p::RollFileBySizeSink>(1024 * 1024, "./log/log_by_size/log");
        Z1->builder_sink_pool<log_p::CoutSink>();
        Z1->build();
    }

}

#endif